package com.wn.controller.demo;

import com.wn.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;

@RestController
@RequestMapping("/prop3")
public class Properties3Controller {

    // 获取一个封装了yml中配置的对象
    @Autowired
    private DataSource dataSource;

    @GetMapping
    public String test() throws SQLException {
        Connection con = dataSource.getConnection();
        PreparedStatement pstmt = con.prepareStatement("delete from article where id=5");
        pstmt.executeUpdate();
        con.close();
        return "ok";
    }

}